package com.iot.ic.modules.service.impl;

import com.iot.ic.modules.dao.PatientCaseDao;
import com.iot.ic.modules.model.PatientCase;
import com.iot.ic.modules.service.PatientCaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("patientCaseService")
public class PatientCaseServiceImpl implements PatientCaseService {
    @Autowired
    private PatientCaseDao patientCaseDao;

    public PatientCase saveOrUpdateObject(PatientCase pc) throws Exception {
        return (PatientCase) patientCaseDao.addOrUpdateObject(pc);
    }

    @Override
    public PatientCase diagnoCase(Integer id, Integer drId, String caseLeave, String diagnoNote) throws Exception {
        boolean success = patientCaseDao.diagnoCase(id, drId, caseLeave, diagnoNote);
        if (success) {
            return patientCaseDao.findById(id);
        } else {
            return null;
        }
    }

    @Override
    public List<PatientCase> findCase(Integer id, Integer userId, Integer drId, String caseLevel, Integer type) throws Exception {
        return patientCaseDao.findCase( id,  userId,  drId,  caseLevel,  type);
    }

    @Override
    public List<PatientCase> findNoticeCase() throws Exception {
        return patientCaseDao.findNoticeCase();
    }
    @Override
    public PatientCase findById(Integer id) throws Exception {
    	return patientCaseDao.findById( id);
    }
}
